<template>
  <div class="system">
    <div class="title">人员信息管理系统</div>
    <hr />
    <div><button @click="changeIsShowModel(true)">新增按钮</button></div>
    <table>
      <thead>
        <tr>
          <th>id</th>
          <th>姓名</th>
          <th>性别</th>
          <th>省份</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item, index) in arr" :key="item.id">
          <td>{{ item.id }}</td>
          <td>{{ item.name }}</td>
          <td>{{ item.gender }}</td>
          <td>{{ item.prov }}</td>
          <td><a href="#" @click.prevent="delPersonInfo(item.id)">删除</a></td>
        </tr>
      </tbody>
    </table>
    <model v-show="isShow"></model>
  </div>
</template>

<script>
import Model from "@/components/Model.vue";
import { mapMutations, mapState } from "vuex";
export default {
  name: "HomeView",
  components: {
    Model,
  },
  computed: {
    ...mapState({
      isShow: (state) => state.showModel.isShow,
      arr: (state) => state.personInfo.arr,
    }),
  },
  methods: {
    ...mapMutations({
      changeIsShowModel:'showModel/changeIsShowModel',
      delInfo: "personInfo/delPersonInfo",
    }),

    delPersonInfo(id){
      this.delInfo(id)
    }
  },
};
</script>

<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
}
.system {
  margin-left: 10px;
  .title {
    height: 30px;
    font-size: 25px;
    line-height: 30px;
    font-weight: 600;
    margin: 10px 0;
  }
  button {
    height: 25px;
    width: 70px;
    margin: 10px 0;
  }
  table {
    float: left;
    border-collapse: collapse;
    text-align: center;
    line-height: 30px;
    margin: 0 auto;
    width: 760px;
  }
  table,td,
  th {
    border: 1px solid #000;
  }
  tr{
    td{
      width: 150px;
    }
  }
}
</style>
